package ptij.ADSL.common;

import ptij.domains.util.BF;

public class FastFECDataFrame extends MuxDataFrame {

    public FastFECDataFrame(int nbAS0, int nbAS1, int nbAS2, int nbAS3, 
        int nbLS0, int nbLS1, int nbLS2, int npar) {
    
        super(nbAS0, nbAS1, nbAS2, nbAS3, nbLS0, nbLS1, nbLS2);
	
	_parity = new int[npar];
    }
            
    public void setParityByte(int b, int nb) {
        _parity[nb] = b;
    }
    
    public int getParityByte(int nb) {
        return _parity[nb];
    }

    public int [] getAsArray() {

        int size = 1 + _AS0.length + _AS1.length + _AS2.length + _AS3.length +
	    _LS0.length + _LS1.length + _LS2.length + _parity.length;
	
	if(_AEXcond) size++;
	if(_LEXcond) size++;
	    
        int ret[] = new int[size];	    
	ret[0] = _fastByte;

	int k = 1;
	for(int i = 0;i < _AS0.length;i++) {
	    ret[k] = _AS0[i];
	    k++;
	}
	for(int i = 0;i < _AS1.length;i++) {
	    ret[k] = _AS1[i];
	    k++;
	}
	for(int i = 0;i < _AS2.length;i++) {
	    ret[k] = _AS2[i];
	    k++;
	}
	for(int i = 0;i < _AS3.length;i++) {
	    ret[k] = _AS3[i];
	    k++;
	}
	for(int i = 0;i < _LS0.length;i++) {
	    ret[k] = _LS0[i];
	    k++;
	}
	for(int i = 0;i < _LS1.length;i++) {
	    ret[k] = _LS1[i];
	    k++;
	}
	for(int i = 0;i < _LS2.length;i++) {
	    ret[k] = _LS2[i];
	    k++;
	}
	if(_AEXcond) {
	    ret[k] = _AEX;
	    k++;
	}
	if(_LEXcond) {
	    ret[k] = _LEX;
	    k++;
	}
	for(int i = 0;i < _parity.length;i++) {
	    ret[k] = _parity[i];
	    k++;	
	}
	
	return ret;    
    }
        
    public void print() {
        super.print();

        int j;
	System.out.println("Reed Solomon Parity bytes (" + _parity.length + "): ");
	for(j = 0;j < _parity.length - 1;j++)
	    System.out.print(BF.byteToHex((byte) _parity[j]) + " ");
	System.out.println(BF.byteToHex((byte) _parity[j]));    
    }

    private int _parity[];
}
